#include "queueapi.h"

#include <stdio.h>

typedef struct QNUM
{
    struct QueueNode fqns;
    int cnt;
} *QNUM;


DEFINE_QUEUE(myqueue);

int main()
{
    queue_init(myqueue);

    struct QNUM n1,n2,n3;
    n1.cnt = 1;
    n2.cnt = 2;
    n3.cnt = 3;
    queue_push(myqueue,&n1);
    queue_push(myqueue,&n2);
    queue_push(myqueue,&n3);
    QueueNode var = queue_pop(myqueue);
    while(var)
    {
        QNUM qvar = CAST_AS(QNUM, var);
        var = queue_pop(myqueue);
        printf("qnode %d\n",qvar->cnt);
    }

    printf("offset of head is %d\n",OFFSET_OF(Queue,last));
    printf("offset of magic is %d\n",OFFSET_OF(Queue,magic));

    Queue q = CONTAINER_OF(Queue, last, &myqueue->last);
    printf("queue magic %lx\n",q->magic);
    printf("hello world\n");
    return 0;    
}